package com.king.hrmsdev.service;

import com.king.hrmsdev.entity.Role;
import com.king.hrmsdev.mapper.RoleMapper;
import com.king.hrmsdev.pojo.Vuserinfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther:SnakeKing
 * @Date: 2019-09-22
 * @Description: com.king.hrmsdev.service
 * @version:1.0
 */
@Service
public class RoleService {
    @Resource
    private RoleMapper roleMapper;

    public List<Role> FindAllRole() {
        List<Role> roleList = roleMapper.FindAllRole();
        return roleList;
    }
    public List<Vuserinfo> FindAllUser() {
        List<Vuserinfo> userList = roleMapper.FindAllUser();
        return userList;
    }




    public int InsertRole(String role) {
        int flag = 1;
        try {
            roleMapper.InsertRole(role);
        } catch (Exception e) {
            flag = 0;
        } finally {
            return flag;
        }
    }


    public int UpdateRole(int role_id,String role) {

        int flag = 1;
        try {

            roleMapper.UpdateRole(role_id,role);
        } catch (Exception e) {
            flag = 0;
        } finally {
            return flag;
        }

    }

    public int Updateuser(Vuserinfo vuserinfo) {
        int flag = 1;
        try {
            roleMapper.Updateuser(vuserinfo);
        } catch (Exception e) {
            flag = 0;
        } finally {
            return flag;
        }

    }


    public int DeleteRole(int role_id) {
        int flag = 1;
        try {
            roleMapper.DeleteRole(role_id);
        } catch (Exception e) {
            flag = 0;
        } finally {
            return flag;
        }
    }

    public int Insertuser(Vuserinfo vuserinfo) {
        int flag = 1;
        try {
            roleMapper.Insertuser(vuserinfo);
        } catch (Exception e) {
            flag = 0;
        } finally {
            return flag;
        }
    }
}
